//
//  ViewController.m
//  综合练习4
//
//  Created by student on 16/3/8.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) IBOutlet UIPageControl *pageControl;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    for(int i=0;i<4;i++)
    {
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(i*320, 0, 320, 568)];
        imgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"new_feature_%i",i]];
        [self.scrollView addSubview:imgView];
    }
    
    self.scrollView.contentSize = CGSizeMake(320*4, 0);
    self.scrollView.showsHorizontalScrollIndicator=NO;
    self.scrollView.pagingEnabled=YES;//分页
    
    self.pageControl.frame=CGRectMake(128, 500, 77, 37);
    UIButton *btn=[[UIButton alloc]initWithFrame:CGRectMake(320*3.5-372/2/2, 400, 372/2, 85/2)];
    [btn setBackgroundImage:[UIImage imageNamed:@"new_feature_button"] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"new_feature_button_highlighted"] forState:UIControlStateHighlighted];
    [btn addTarget:self action:@selector(btnPressed) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollView addSubview:btn];
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    self.pageControl.currentPage = scrollView.contentOffset.x / 320;
}
- (void)btnPressed
{
    NSLog(@"%s",__func__);
    
    // 沿着某条线跳转
    [self performSegueWithIdentifier:@"gotoMain" sender:nil];
}


@end
